package com.hyfrogx.modules.information.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hyfrogx.common.utils.QueryExt;
import com.hyfrogx.modules.app.form.information.VerifyMediaForm;
import com.hyfrogx.modules.app.utils.FrogConstant;
import com.hyfrogx.modules.information.dao.HyInformationVerifyDao;
import com.hyfrogx.modules.information.entity.HyInformationVerifyEntity;
import com.hyfrogx.modules.information.service.HyInformationVerifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author liubin
 * @date 2019/10/21 10:50
 */
@Service("HyInformationVerifyService")
@Slf4j
public class HyInformationVerifyServiceImpl
  extends ServiceImpl<HyInformationVerifyDao, HyInformationVerifyEntity> implements HyInformationVerifyService {

  @Override
  public HyInformationVerifyEntity getVerifyRecordByUid(Integer uid) {
    return getBaseMapper().getVerifyRecordByUid(uid);
  }

  @Override
  public Page getAllVerifyRecord(QueryExt query) {
    Map map = new HashMap(16);
    map.putAll(query.getCondition());
    List<HyInformationVerifyEntity> result = this.baseMapper.getAllVerifyRecord(query,map);
    query.setRecords(result);
    return query;
  }

  @Override
  public Page getAllNotFollowClient(QueryExt query) {
    Map map = new HashMap(16);
    map.putAll(query.getCondition());
    List<HyInformationVerifyEntity> result = this.baseMapper.getAllNotFollowClient(query,map);
    query.setRecords(result);
    return query;
  }

  @Override
  public List<HyInformationVerifyEntity> getAllRecommendReordClient() {
    return this.baseMapper.getAllRecommendReordClient();
  }

  @Override
  public List<HyInformationVerifyEntity> getAllFollowRecordClient1(Integer fid) {
    return getBaseMapper().getAllFollowRecordClient1(fid);
  }

  @Override
  public Page getAllFollowRecordClient(QueryExt query) {
    Map map = new HashMap(16);
    map.putAll(query.getCondition());
    List<HyInformationVerifyEntity> result = this.baseMapper.getAllFollowRecordClient(query,map);
    query.setRecords(result);
    return query;
  }

  @Override
  public Integer commitVerify(VerifyMediaForm verifyMedia,Long userId){
    HyInformationVerifyEntity hyInformationVerify = new HyInformationVerifyEntity();
    BeanUtils.copyProperties(verifyMedia,hyInformationVerify);
    hyInformationVerify.setCreateTime(new Date());
    hyInformationVerify.setUid(userId.intValue());
    hyInformationVerify.setVerifyStatus(FrogConstant.InformationVerify.PENDING);
    return this.baseMapper.insert(hyInformationVerify);
  }

  @Override
  public HyInformationVerifyEntity getAccountByUid(Long userId) {
    return this.baseMapper.getAccountByUid(userId);
  }

  @Override
  public Page getAllOperationCenter(QueryExt query) {
    Map map = new HashMap(16);
    map.putAll(query.getCondition());
    List<HyInformationVerifyEntity> result = this.baseMapper.getAllOperationCenter(query,map);
    query.setRecords(result);
    return query;
  }

}
